/**
 * Copyright (c) 2000-2012 Liferay, Inc. All rights reserved.
 *
 * This library is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Lesser General Public License as published by the Free
 * Software Foundation; either version 2.1 of the License, or (at your option)
 * any later version.
 *
 * This library is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
 * details.
 */

package com.vportal.portlet.vfaq.model.impl;

import com.liferay.portal.kernel.bean.AutoEscapeBeanHandler;
import com.liferay.portal.kernel.exception.SystemException;
import com.liferay.portal.kernel.util.DateUtil;
import com.liferay.portal.kernel.util.GetterUtil;
import com.liferay.portal.kernel.util.ProxyUtil;
import com.liferay.portal.kernel.util.StringBundler;
import com.liferay.portal.kernel.util.StringPool;
import com.liferay.portal.model.CacheModel;
import com.liferay.portal.model.impl.BaseModelImpl;
import com.liferay.portal.service.ServiceContext;
import com.liferay.portal.util.PortalUtil;

import com.liferay.portlet.expando.model.ExpandoBridge;
import com.liferay.portlet.expando.util.ExpandoBridgeFactoryUtil;

import com.vportal.portlet.vfaq.model.FAQCategory;
import com.vportal.portlet.vfaq.model.FAQCategoryModel;

import java.io.Serializable;

import java.sql.Types;

import java.util.Date;

/**
 * The base model implementation for the FAQCategory service. Represents a row in the &quot;FAQCategory&quot; database table, with each column mapped to a property of this class.
 *
 * <p>
 * This implementation and its corresponding interface {@link com.vportal.portlet.vfaq.model.FAQCategoryModel} exist only as a container for the default property accessors generated by ServiceBuilder. Helper methods and all application logic should be put in {@link FAQCategoryImpl}.
 * </p>
 *
 * @author DucNN
 * @see FAQCategoryImpl
 * @see com.vportal.portlet.vfaq.model.FAQCategory
 * @see com.vportal.portlet.vfaq.model.FAQCategoryModel
 * @generated
 */
public class FAQCategoryModelImpl extends BaseModelImpl<FAQCategory>
	implements FAQCategoryModel {
	/*
	 * NOTE FOR DEVELOPERS:
	 *
	 * Never modify or reference this class directly. All methods that expect a f a q category model instance should use the {@link com.vportal.portlet.vfaq.model.FAQCategory} interface instead.
	 */
	public static final String TABLE_NAME = "FAQCategory";
	public static final Object[][] TABLE_COLUMNS = {
			{ "id_", Types.BIGINT },
			{ "name", Types.VARCHAR },
			{ "description", Types.VARCHAR },
			{ "language", Types.VARCHAR },
			{ "parent", Types.BIGINT },
			{ "catorder", Types.BIGINT },
			{ "catlevel", Types.BIGINT },
			{ "image", Types.VARCHAR },
			{ "createdByUser", Types.VARCHAR },
			{ "createdDate", Types.TIMESTAMP },
			{ "modifiedByUser", Types.VARCHAR },
			{ "modifiedDate", Types.TIMESTAMP },
			{ "groupId", Types.BIGINT },
			{ "userId", Types.BIGINT }
		};
	public static final String TABLE_SQL_CREATE = "create table FAQCategory (id_ LONG not null primary key,name VARCHAR(1000) null,description VARCHAR(2000) null,language VARCHAR(150) null,parent LONG,catorder LONG,catlevel LONG,image VARCHAR(500) null,createdByUser VARCHAR(300) null,createdDate DATE null,modifiedByUser VARCHAR(300) null,modifiedDate DATE null,groupId LONG,userId LONG)";
	public static final String TABLE_SQL_DROP = "drop table FAQCategory";
	public static final String ORDER_BY_JPQL = " ORDER BY faqCategory.createdDate DESC";
	public static final String ORDER_BY_SQL = " ORDER BY FAQCategory.createdDate DESC";
	public static final String DATA_SOURCE = "liferayDataSource";
	public static final String SESSION_FACTORY = "liferaySessionFactory";
	public static final String TX_MANAGER = "liferayTransactionManager";
	public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.util.service.ServiceProps.get(
				"value.object.entity.cache.enabled.com.vportal.portlet.vfaq.model.FAQCategory"),
			true);
	public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.util.service.ServiceProps.get(
				"value.object.finder.cache.enabled.com.vportal.portlet.vfaq.model.FAQCategory"),
			true);
	public static final boolean COLUMN_BITMASK_ENABLED = GetterUtil.getBoolean(com.liferay.util.service.ServiceProps.get(
				"value.object.column.bitmask.enabled.com.vportal.portlet.vfaq.model.FAQCategory"),
			true);
	public static long GROUPID_COLUMN_BITMASK = 1L;
	public static long ID_COLUMN_BITMASK = 2L;
	public static long LANGUAGE_COLUMN_BITMASK = 4L;
	public static long PARENT_COLUMN_BITMASK = 8L;
	public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.util.service.ServiceProps.get(
				"lock.expiration.time.com.vportal.portlet.vfaq.model.FAQCategory"));

	public FAQCategoryModelImpl() {
	}

	public long getPrimaryKey() {
		return _id;
	}

	public void setPrimaryKey(long primaryKey) {
		setId(primaryKey);
	}

	public Serializable getPrimaryKeyObj() {
		return new Long(_id);
	}

	public void setPrimaryKeyObj(Serializable primaryKeyObj) {
		setPrimaryKey(((Long)primaryKeyObj).longValue());
	}

	public Class<?> getModelClass() {
		return FAQCategory.class;
	}

	public String getModelClassName() {
		return FAQCategory.class.getName();
	}

	public long getId() {
		return _id;
	}

	public void setId(long id) {
		_columnBitmask |= ID_COLUMN_BITMASK;

		if (!_setOriginalId) {
			_setOriginalId = true;

			_originalId = _id;
		}

		_id = id;
	}

	public long getOriginalId() {
		return _originalId;
	}

	public String getName() {
		if (_name == null) {
			return StringPool.BLANK;
		}
		else {
			return _name;
		}
	}

	public void setName(String name) {
		_name = name;
	}

	public String getDescription() {
		if (_description == null) {
			return StringPool.BLANK;
		}
		else {
			return _description;
		}
	}

	public void setDescription(String description) {
		_description = description;
	}

	public String getLanguage() {
		if (_language == null) {
			return StringPool.BLANK;
		}
		else {
			return _language;
		}
	}

	public void setLanguage(String language) {
		_columnBitmask |= LANGUAGE_COLUMN_BITMASK;

		if (_originalLanguage == null) {
			_originalLanguage = _language;
		}

		_language = language;
	}

	public String getOriginalLanguage() {
		return GetterUtil.getString(_originalLanguage);
	}

	public long getParent() {
		return _parent;
	}

	public void setParent(long parent) {
		_columnBitmask |= PARENT_COLUMN_BITMASK;

		if (!_setOriginalParent) {
			_setOriginalParent = true;

			_originalParent = _parent;
		}

		_parent = parent;
	}

	public long getOriginalParent() {
		return _originalParent;
	}

	public long getCatorder() {
		return _catorder;
	}

	public void setCatorder(long catorder) {
		_catorder = catorder;
	}

	public long getCatlevel() {
		return _catlevel;
	}

	public void setCatlevel(long catlevel) {
		_catlevel = catlevel;
	}

	public String getImage() {
		if (_image == null) {
			return StringPool.BLANK;
		}
		else {
			return _image;
		}
	}

	public void setImage(String image) {
		_image = image;
	}

	public String getCreatedByUser() {
		if (_createdByUser == null) {
			return StringPool.BLANK;
		}
		else {
			return _createdByUser;
		}
	}

	public void setCreatedByUser(String createdByUser) {
		_createdByUser = createdByUser;
	}

	public Date getCreatedDate() {
		return _createdDate;
	}

	public void setCreatedDate(Date createdDate) {
		_columnBitmask = -1L;

		_createdDate = createdDate;
	}

	public String getModifiedByUser() {
		if (_modifiedByUser == null) {
			return StringPool.BLANK;
		}
		else {
			return _modifiedByUser;
		}
	}

	public void setModifiedByUser(String modifiedByUser) {
		_modifiedByUser = modifiedByUser;
	}

	public Date getModifiedDate() {
		return _modifiedDate;
	}

	public void setModifiedDate(Date modifiedDate) {
		_modifiedDate = modifiedDate;
	}

	public long getGroupId() {
		return _groupId;
	}

	public void setGroupId(long groupId) {
		_columnBitmask |= GROUPID_COLUMN_BITMASK;

		if (!_setOriginalGroupId) {
			_setOriginalGroupId = true;

			_originalGroupId = _groupId;
		}

		_groupId = groupId;
	}

	public long getOriginalGroupId() {
		return _originalGroupId;
	}

	public long getUserId() {
		return _userId;
	}

	public void setUserId(long userId) {
		_userId = userId;
	}

	public String getUserUuid() throws SystemException {
		return PortalUtil.getUserValue(getUserId(), "uuid", _userUuid);
	}

	public void setUserUuid(String userUuid) {
		_userUuid = userUuid;
	}

	public long getColumnBitmask() {
		return _columnBitmask;
	}

	@Override
	public FAQCategory toEscapedModel() {
		if (_escapedModelProxy == null) {
			_escapedModelProxy = (FAQCategory)ProxyUtil.newProxyInstance(_classLoader,
					_escapedModelProxyInterfaces,
					new AutoEscapeBeanHandler(this));
		}

		return _escapedModelProxy;
	}

	@Override
	public ExpandoBridge getExpandoBridge() {
		if (_expandoBridge == null) {
			_expandoBridge = ExpandoBridgeFactoryUtil.getExpandoBridge(0,
					FAQCategory.class.getName(), getPrimaryKey());
		}

		return _expandoBridge;
	}

	@Override
	public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
		getExpandoBridge().setAttributes(serviceContext);
	}

	@Override
	public Object clone() {
		FAQCategoryImpl faqCategoryImpl = new FAQCategoryImpl();

		faqCategoryImpl.setId(getId());
		faqCategoryImpl.setName(getName());
		faqCategoryImpl.setDescription(getDescription());
		faqCategoryImpl.setLanguage(getLanguage());
		faqCategoryImpl.setParent(getParent());
		faqCategoryImpl.setCatorder(getCatorder());
		faqCategoryImpl.setCatlevel(getCatlevel());
		faqCategoryImpl.setImage(getImage());
		faqCategoryImpl.setCreatedByUser(getCreatedByUser());
		faqCategoryImpl.setCreatedDate(getCreatedDate());
		faqCategoryImpl.setModifiedByUser(getModifiedByUser());
		faqCategoryImpl.setModifiedDate(getModifiedDate());
		faqCategoryImpl.setGroupId(getGroupId());
		faqCategoryImpl.setUserId(getUserId());

		faqCategoryImpl.resetOriginalValues();

		return faqCategoryImpl;
	}

	public int compareTo(FAQCategory faqCategory) {
		int value = 0;

		value = DateUtil.compareTo(getCreatedDate(),
				faqCategory.getCreatedDate());

		value = value * -1;

		if (value != 0) {
			return value;
		}

		return 0;
	}

	@Override
	public boolean equals(Object obj) {
		if (obj == null) {
			return false;
		}

		FAQCategory faqCategory = null;

		try {
			faqCategory = (FAQCategory)obj;
		}
		catch (ClassCastException cce) {
			return false;
		}

		long primaryKey = faqCategory.getPrimaryKey();

		if (getPrimaryKey() == primaryKey) {
			return true;
		}
		else {
			return false;
		}
	}

	@Override
	public int hashCode() {
		return (int)getPrimaryKey();
	}

	@Override
	public void resetOriginalValues() {
		FAQCategoryModelImpl faqCategoryModelImpl = this;

		faqCategoryModelImpl._originalId = faqCategoryModelImpl._id;

		faqCategoryModelImpl._setOriginalId = false;

		faqCategoryModelImpl._originalLanguage = faqCategoryModelImpl._language;

		faqCategoryModelImpl._originalParent = faqCategoryModelImpl._parent;

		faqCategoryModelImpl._setOriginalParent = false;

		faqCategoryModelImpl._originalGroupId = faqCategoryModelImpl._groupId;

		faqCategoryModelImpl._setOriginalGroupId = false;

		faqCategoryModelImpl._columnBitmask = 0;
	}

	@Override
	public CacheModel<FAQCategory> toCacheModel() {
		FAQCategoryCacheModel faqCategoryCacheModel = new FAQCategoryCacheModel();

		faqCategoryCacheModel.id = getId();

		faqCategoryCacheModel.name = getName();

		String name = faqCategoryCacheModel.name;

		if ((name != null) && (name.length() == 0)) {
			faqCategoryCacheModel.name = null;
		}

		faqCategoryCacheModel.description = getDescription();

		String description = faqCategoryCacheModel.description;

		if ((description != null) && (description.length() == 0)) {
			faqCategoryCacheModel.description = null;
		}

		faqCategoryCacheModel.language = getLanguage();

		String language = faqCategoryCacheModel.language;

		if ((language != null) && (language.length() == 0)) {
			faqCategoryCacheModel.language = null;
		}

		faqCategoryCacheModel.parent = getParent();

		faqCategoryCacheModel.catorder = getCatorder();

		faqCategoryCacheModel.catlevel = getCatlevel();

		faqCategoryCacheModel.image = getImage();

		String image = faqCategoryCacheModel.image;

		if ((image != null) && (image.length() == 0)) {
			faqCategoryCacheModel.image = null;
		}

		faqCategoryCacheModel.createdByUser = getCreatedByUser();

		String createdByUser = faqCategoryCacheModel.createdByUser;

		if ((createdByUser != null) && (createdByUser.length() == 0)) {
			faqCategoryCacheModel.createdByUser = null;
		}

		Date createdDate = getCreatedDate();

		if (createdDate != null) {
			faqCategoryCacheModel.createdDate = createdDate.getTime();
		}
		else {
			faqCategoryCacheModel.createdDate = Long.MIN_VALUE;
		}

		faqCategoryCacheModel.modifiedByUser = getModifiedByUser();

		String modifiedByUser = faqCategoryCacheModel.modifiedByUser;

		if ((modifiedByUser != null) && (modifiedByUser.length() == 0)) {
			faqCategoryCacheModel.modifiedByUser = null;
		}

		Date modifiedDate = getModifiedDate();

		if (modifiedDate != null) {
			faqCategoryCacheModel.modifiedDate = modifiedDate.getTime();
		}
		else {
			faqCategoryCacheModel.modifiedDate = Long.MIN_VALUE;
		}

		faqCategoryCacheModel.groupId = getGroupId();

		faqCategoryCacheModel.userId = getUserId();

		return faqCategoryCacheModel;
	}

	@Override
	public String toString() {
		StringBundler sb = new StringBundler(29);

		sb.append("{id=");
		sb.append(getId());
		sb.append(", name=");
		sb.append(getName());
		sb.append(", description=");
		sb.append(getDescription());
		sb.append(", language=");
		sb.append(getLanguage());
		sb.append(", parent=");
		sb.append(getParent());
		sb.append(", catorder=");
		sb.append(getCatorder());
		sb.append(", catlevel=");
		sb.append(getCatlevel());
		sb.append(", image=");
		sb.append(getImage());
		sb.append(", createdByUser=");
		sb.append(getCreatedByUser());
		sb.append(", createdDate=");
		sb.append(getCreatedDate());
		sb.append(", modifiedByUser=");
		sb.append(getModifiedByUser());
		sb.append(", modifiedDate=");
		sb.append(getModifiedDate());
		sb.append(", groupId=");
		sb.append(getGroupId());
		sb.append(", userId=");
		sb.append(getUserId());
		sb.append("}");

		return sb.toString();
	}

	public String toXmlString() {
		StringBundler sb = new StringBundler(46);

		sb.append("<model><model-name>");
		sb.append("com.vportal.portlet.vfaq.model.FAQCategory");
		sb.append("</model-name>");

		sb.append(
			"<column><column-name>id</column-name><column-value><![CDATA[");
		sb.append(getId());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>name</column-name><column-value><![CDATA[");
		sb.append(getName());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>description</column-name><column-value><![CDATA[");
		sb.append(getDescription());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>language</column-name><column-value><![CDATA[");
		sb.append(getLanguage());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>parent</column-name><column-value><![CDATA[");
		sb.append(getParent());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>catorder</column-name><column-value><![CDATA[");
		sb.append(getCatorder());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>catlevel</column-name><column-value><![CDATA[");
		sb.append(getCatlevel());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>image</column-name><column-value><![CDATA[");
		sb.append(getImage());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>createdByUser</column-name><column-value><![CDATA[");
		sb.append(getCreatedByUser());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>createdDate</column-name><column-value><![CDATA[");
		sb.append(getCreatedDate());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>modifiedByUser</column-name><column-value><![CDATA[");
		sb.append(getModifiedByUser());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>modifiedDate</column-name><column-value><![CDATA[");
		sb.append(getModifiedDate());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>groupId</column-name><column-value><![CDATA[");
		sb.append(getGroupId());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>userId</column-name><column-value><![CDATA[");
		sb.append(getUserId());
		sb.append("]]></column-value></column>");

		sb.append("</model>");

		return sb.toString();
	}

	private static ClassLoader _classLoader = FAQCategory.class.getClassLoader();
	private static Class<?>[] _escapedModelProxyInterfaces = new Class[] {
			FAQCategory.class
		};
	private long _id;
	private long _originalId;
	private boolean _setOriginalId;
	private String _name;
	private String _description;
	private String _language;
	private String _originalLanguage;
	private long _parent;
	private long _originalParent;
	private boolean _setOriginalParent;
	private long _catorder;
	private long _catlevel;
	private String _image;
	private String _createdByUser;
	private Date _createdDate;
	private String _modifiedByUser;
	private Date _modifiedDate;
	private long _groupId;
	private long _originalGroupId;
	private boolean _setOriginalGroupId;
	private long _userId;
	private String _userUuid;
	private transient ExpandoBridge _expandoBridge;
	private long _columnBitmask;
	private FAQCategory _escapedModelProxy;
}